
#ifndef tlmServiceElement_H
#define tlmServiceElement_H

#include "tlmService.h"
//## operation Fill(tlmServiceMsg)
class tlmServiceMsg;

//## attribute mpMsgBuf
class msgbuf;



//## class tlmServiceElement
// This is the base class for Remote Configuration Element which contains code and value.
// The default value is 1 byte.
class tlmServiceElement {
    ////    Friends    ////
    
public :


    ////    Constructors and destructors    ////
    
    //## operation tlmServiceElement(uint8_t,uint32_t)
    tlmServiceElement(uint8_t code, uint32_t size);
    
    //## operation tlmServiceElement(uint8_t)
    tlmServiceElement(uint8_t code);
    
    //## operation ~tlmServiceElement()
    ~tlmServiceElement();
    
    ////    Operations    ////
    
    // Fill message buffer with  code&value of the element
    // For default element such as NGTP header element, there is no sep between code and value
    //## operation Fill(tlmServiceMsg)
    virtual void Fill(tlmServiceMsg& srvMsg);
    
    // This function get element value from message buffer and save it.
    // This can only be used for fixed size element , such as header element.
    // The datainfo element has escape byte, so the length is different.It should use another way to init the value.
    //## operation ParseInit(tlmServiceMsg) const
    bool_t ParseInit(tlmServiceMsg& srvMsg) const;
    
    // For default element, no need to set mIsUpdated
    // but for parameters element, when set the value, should set the flag. It shall be override in tlmServiceElementPara class
    //## operation SetUpdatedFlag()
    virtual void SetUpdatedFlag();
    
    //## operation SetValue(uint8_t*)
    void SetValue(uint8_t* pValue);
    
    ////    Additional operations    ////
    
    //## auto_generated
    uint8_t getMCode() const;
    
    //## auto_generated
    void setMCode(uint8_t p_mCode);
    
    //## auto_generated
    bool_t getMIsUpdated() const;
    
    //## auto_generated
    void setMIsUpdated(bool_t p_mIsUpdated);
    
    //## auto_generated
    uint32_t getMSize() const;
    
    //## auto_generated
    void setMSize(uint32_t p_mSize);
    
    //## auto_generated
    uint8_t* getMValuePtr() const;
    
    //## auto_generated
    void setMValuePtr(uint8_t* p_mValuePtr);
    
    //## auto_generated
    msgbuf* getMpMsgBuf() const;
    
    //## auto_generated
    void setMpMsgBuf(msgbuf* p_mpMsgBuf);
    
    ////    Attributes    ////

public :

    //## auto_generated
    tlmServiceElement();
    
    // Fill message buffer with  code&value of the element
    // For default element such as NGTP header element, there is no sep between code and value
    //## operation Fill(msgbuf)
    virtual void Fill(msgbuf*& pMsgBuf);
    
    //## operation SetValue(uint8_t*,uint32_t)
    void SetValue(uint8_t* pValue, uint32_t size);
    
    //## operation GetValuePtr() const
    uint8_t* GetValuePtr() const;
    //## operation IsUpdated() const
    bool_t IsUpdated() const;
    //## operation GetActualSize() const
    uint32_t GetActualSize() const;

protected :

    // For some element ,eg. url, the actual size is not same as default size(max size)
    uint32_t mActualSize;		//## attribute mActualSize

    // this is the size of element value,
    // default element's size is 1 byte.
    uint32_t mSize;		//## attribute mSize

    msgbuf* mpMsgBuf;		//## attribute mpMsgBuf
    // This is the pointer that point the address of element value.
    // As different element has different value size, use a pointer of value address
    uint8_t* mValuePtr;		//## attribute mValuePtr

    uint8_t mCode;		//## attribute mCode
    
    bool_t mIsUpdated;		//## attribute mIsUpdated
    
    
    

};
#endif
